﻿using Inovout.Component;
using Inovout.Data.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace KuaJing.Memberships.Domain
{
    public partial class Actor
    {
        protected Actor(Membership membership, string name, string alias, string type)
            : this(name, alias, type)
        {
            this.Memberships.Add(membership);
        }
        protected Actor(string name, string alias, string type)
        {
            this.Name = name;
            this.Alias = alias;
            this.type = type;
        }
        internal static Actor GetGeneralActor(Membership membership)
        {
            return ComponentRegistry.Resolve<IRepository<Actor>>().Query().SingleOrDefault(actor => actor.Name.Equals("General"))
                ?? new Actor(membership, "General", "普通会员", "Fefault");
        }
    }
}
